#!/bin/sh
################################################################################
# mm_detect
#
# This is a wrapper that calls functions in /lib/minimyth/mm_detect on behalf
# of udev.
################################################################################

. /lib/minimyth/mm_detect

group=$1
name=$2
state=$3
flags=$4

if /usr/bin/test -z "${group}" || /usr/bin/test -z "${name}"  ; then
    exit 1
fi

if /bin/echo ",${flags}," | /bin/grep -q -e ',state_prepend_devname,' > /dev/null 2>&1 ; then
    if /usr/bin/test -z "${state}" ; then
        state="${DEVNAME}"
    else
        state="${DEVNAME},${state}"
    fi
fi

case "${ACTION}" in
    add)    mm_detect_state_set   "${group}" "${name}" "${state}" ;;
    remove) mm_detect_state_unset "${group}" "${name}"            ;;
esac

exit 0
